﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Cosmetic.DataEntity;
using System.Collections;

namespace Cosmetic.Logic
{
    /// <summary>
    /// 
    /// </summary>
    public class PackageSaleManager : LogicBase
    {
        public List<PackageSale> GetPackageSaleAll()
        {
            List<PackageSale> result = (from thePackage in m_CosmeticDC.PackageSales
                                        select thePackage).ToList();
            return result;
        }

        public ProductInfo GetProductInfoById(Guid ProductId)
        {
            ProductInfo result = (from theProductInfo in m_CosmeticDC.ProductInfos
                                  where theProductInfo.ProductId == ProductId
                                  select theProductInfo).Single();
            return result;
        }

        /// <summary>
        /// 
        /// </summary>
        /// <param name="ht"></param>
        /// <returns></returns>
        public List<PackageSale> GetPackageSales(Hashtable ht)
        {
            Guid[] pp = new Guid[ht.Count];
            int i = 0;

            foreach (DictionaryEntry entry in ht)
            {
                pp[i] = new Guid(entry.Key.ToString());
                i++;
            }

            var result = (from gpt in m_CosmeticDC.PackageSales
                          where pp.Contains(gpt.Id)
                          select gpt).ToList();
                          //{
                          //    PackageId = gpt.Id,
                          //    ProductId1 = gpt.ProductId1,
                          //    ProductId2 = gpt.ProductId2,
                          //    ProductId3 = gpt.ProductId3,
                          //    CurrentPrice = gpt.CurrentPrice,
                          //    ViewTimes = gpt.ViewTimes
                          //    //Count = ht[gpt.ProductId.ToString()].ToString(),
                          //    //ProductSmallPrice ="1"// Convert.ToInt32(ht[gpt.ProductId]) * gpt.Price,
                          //}).ToList();

            return result;
        }

    }
}
